<?php
	include 'config.php';
	include 'logger.php';
	
	session_start();		
	
	
	if(isset($_SESSION['logged_in']))
	{
		if(!$_SESSION['logged_in'] == TRUE)
		{
			header(sprintf("Location: %s", "php/403forbidden.php"));
			exit();
		} else
		{
			$iprecreate = $_SERVER['REMOTE_ADDR'];
			$useragentrecreate = $_SERVER['HTTP_USER_AGENT'];
			$signaturerecreate = $_SESSION['signature'];			
			
			$saltrecreate = substr($signaturerecreate, 0, 15);
			$originalhash = substr($signaturerecreate, 15, strlen($signaturerecreate));
			
			$hashrecreate = sha1($saltrecreate . $iprecreate . $useragentrecreate );	

			if($hashrecreate != $originalhash)
			{
				header(sprintf("Location: %s", "php/403forbidden.php"));
			}
		}
	} else
	{
		header(sprintf("Location: %s", "login.php"));
	}
	